<template>
	<view class="bg-white">
		<cu-custom bgColor="bg-white" :isBack="true">
			<block slot="content">调岗申请详情</block>

		</cu-custom>
		<view style="position: relative;" class="padding bg-white">
			<view class="text-cut padding" style="background-color: #F3F5FC ;color: #696969;border-radius: 15px;">
				完成时间：<text style="padding-left: 30px;">{{dataObj.updateTime}}</text>
			</view>
			<view
				style="padding: 3px 10px;position: absolute; right: 17px; top: 17px;border-radius: 0rpx 20rpx 0rpx 20rpx; background-color: #3085FE ;color: #FFFFFF;">
				<text>进行中</text>
			</view>

		</view>

		<view>
			<view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					申请人
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.userId_dictText}}
				</view>
			</view>
		<!-- 	<view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					申请日期
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.createTime}}
				</view>
			</view> -->
			<view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					调岗时间
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.jobTransferTime}}
				</view>
			</view>
			<view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					调岗类型
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.jobTransferType_dictText}}
				</view>
			</view>
			<!-- <view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					姓名
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.userId_dictText}}
				</view>
			</view> -->
			<view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					工号
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.workNo}}
				</view>
			</view>
			<view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					性别
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.sex_dictText}}
				</view>
			</view>
			<view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					年龄
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.age}}
				</view>
			</view>
			<!-- <view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					学历
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.education}}
				</view>
			</view> -->
			<view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					公司
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.company_dictText}}
				</view>
			</view>
			<view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					原部门
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.orgCodeTxt}}
				</view>
			</view>

			<view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					原岗位
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.post}}
				</view>
			</view>
			
			<view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					原车间
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.workshop}}
				</view>
			</view>
			<view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					原岗位
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.post}}
				</view>
			</view>
			
			<view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					是否使用新工号
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.newWorkNoFlag_dictText}}
				</view>
			</view>
			<view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					新工号
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.newWorkNo}}
				</view>
			</view>
			<view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					转入公司
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.newCompany_dictText}}
				</view>
			</view>
			<view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					转入部门
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.newClassification}}
				</view>
			</view>

			<view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					转入岗位
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.newPost}}
				</view>
			</view>
			<view class="flex">
				<view class="flex-sub padding-sm margin-xs radius">
					调岗原因
				</view>
				<view class="flex-sub padding-sm margin-xs radius">
					{{dataObj.reason}}
				</view>
			</view>
		</view>

		<view style="margin-top: 15px;">
			<view class="action" style="margin-bottom: 10px;">
				<text class="cuIcon-titles " style="color: #1E5EFF;"></text>
				<text style="color: #000000;font-weight: bold;font-size: 30rpx;">
					审批记录
				</text>
			</view>
			<view style="background-color: #f4f4f4;border-radius: 10px;margin-top: 10px;">
				<view class="cu-timeline" v-for="(item,index) in approvalRecords">
					<view class="cu-item text-green cuIcon-roundcheckfill">
						<view style="display: flex;color: #000000;">
							<view style="width: 25px;">
								<text
									style="margin-left: -18px;margin-top: 5px;display: block;font-weight: bold;">{{item.currentNodeDictText}}</text>
							</view>
							<view style="margin-left: 20px;">
								<view>
									<text style="font-size: 28rpx;">{{item.approverDictText}}</text>
									<text
										style="display: inline-block;padding: 2px;background-color: #d9d9d9;border-radius: 5px;font-size: 16rpx;margin-left: 10px;color: #a1a1a1;">{{item.remark}}</text>
                  <text v-if="item.approvalStatusDictText == '同意'"
                        style="display: inline-block;padding: 4rpx 10rpx;background-color: #34b483;border-radius: 5px;font-size: 16rpx;margin-left: 15px;color: #FFFFFF;">{{item.approvalStatusDictText}}</text>
                  <text v-if="item.approvalStatusDictText == '待审'"
                        style="display: inline-block;padding: 4rpx 10rpx;background-color: #c6ffbe;border-radius: 5px;font-size: 16rpx;margin-left: 15px;color: #48B237;">{{item.approvalStatusDictText}}</text>
                  <text v-if="item.approvalStatusDictText == '驳回'"
                        style="display: inline-block;padding: 4rpx 10rpx;background-color: #f5222d;border-radius: 5px;font-size: 16rpx;margin-left: 15px;color: #FFFFFF;">{{item.approvalStatusDictText}}</text>
                  <text v-if="item.approvalStatusDictText == '结束'"
                        style="display: inline-block;padding: 4rpx 10rpx;background-color: #D9D9D9;border-radius: 5px;font-size: 16rpx;margin-left: 15px;color: #A0A0A0;">{{item.approvalStatusDictText}}</text>
								</view>
								<view>
									<text style="font-size: 24rpx;">{{item.approvalTypeDictText}}</text>
									<text
										style="font-size: 20rpx;color: #c7c7c7;margin-left: 15px;">{{item.createTime}}</text>
								</view>
							</view>

						</view>
					</view>
				</view>
			</view>
		</view>
		<view v-if="isShowBtn" style="display: flex;justify-content: space-around;align-items: center;padding-top: 20rpx;padding-bottom: 20rpx;">
			<view @click.stop="agree()">
				<button
					style="background-color: rgba(69, 145, 254, 1);border-radius: 20rpx;font-size:12px;padding: 10rpx 70rpx;color: rgba(255, 255, 255, 1);display: inline-block; ">同意</button>
			</view>
			<view  @click.stop="disagree()">
				<button
					style="background-color: rgba(167, 52, 52, 1);border-radius: 20rpx;font-size:12px;padding: 10rpx 70rpx;color: rgba(255, 255, 255, 1);display: inline-block;">驳回</button>
			</view>
		</view>
		
		
		<uni-popup ref="agreePopup" background-color="#fff" :mask-click="false">
			<view
				style="text-align: center;background-color: #FFFFFF;padding: 11rpx;width: 580rpx;height: 470rpx;border-radius: 42rpx;">
				<view class="submit-item">
					<image class="submit-icon" src="@/static/images/editUserIcon.png" />
				</view>
				<view style="margin-top: 28rpx;">
					<text class="submit-text">确定要同意该申请吗</text>
				</view>
				<br>
				<view style="display: flex;">
					<button @click="sureAgree" style="border-radius: 20rpx; background-color: rgba(69, 145, 254, 1);
							color: rgba(255, 255, 255, 1);width: 230rpx;margin-top: 50rpx;">确定</button>
					<button @click="cancelAgree" style="border-radius: 20rpx; background-color: gray;
							color: rgba(255, 255, 255, 1);width: 230rpx;margin-top: 50rpx;">取消</button>
				</view>
			</view>
		</uni-popup>
		<uni-popup ref="isAgree" background-color="#fff" :mask-click="false">
			<view
				style="text-align: center;background-color: #FFFFFF;padding: 11rpx;width: 580rpx;height: 470rpx;border-radius: 42rpx;">
				<view class="submit-item">
					<image class="submit-icon" src="@/static/zhinengshenheshenchashenhe 1.png" />
				</view>
				<view style="margin-top: 28rpx;">
					<text class="submit-text">你已同意用户的申请</text>
				</view>
				<button @click="agreeCancel" style="border-radius: 20rpx; background-color: rgba(69, 145, 254, 1);
				color: rgba(255, 255, 255, 1);width: 300rpx;margin-top: 27rpx;">确定</button>
			</view>
		</uni-popup>
		<uni-popup ref="isDisagree" background-color="#fff" :mask-click="false">
			<view
				style="background-color: #FFFFFF;padding: 11rpx 30rpx;width: 580rpx;height: 400rpx;border-radius: 42rpx;">
				<view style="margin-top: 28rpx;margin-left: 15rpx;">
					<text class="submit-text">驳回</text>
				</view>
				<view class="cu-form-group"
					style="background-color: rgba(243, 243, 243, 1);border-radius: 15px;margin-top: 40rpx;height: 100rpx;">
					<input v-model="rejectReason" placeholder="请输入驳回理由" name="input" style="font-size: 25rpx;"></input>
				</view>
				<button style="background-color: rgba(217, 217, 217, 1);
							color: rgba(86, 85, 85, 1); margin-top: 30rpx;padding: 2rpx 85rpx; display: inline-block; "
					@click="rejectCancel">取消</button>
				<button style="background-color: rgba(69, 145, 254, 1);
				color: rgba(255, 255, 255, 1);margin-left:34rpx; display: inline-block;padding: 2rpx 85rpx; "
					@click="rejectSure">确定</button>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import moment from 'moment';
	export default {
		data() {
			return {
				isShowBtn:false,
				examineId:'',
				rejectReason:'',
				createTime: '2023/09/21 14:00:23',
				dataObj: {},
				approvalRecords: [],
			}
		},
		mounted() {
			this.getDetail()
		},
		computed: {

		},
		onLoad: function(options) {
			this.dataObj.id = options.id;
			// 在这里可以使用获取到的 id 参数进行后续操作
			if(options.status && options.status == 3) {
				this.isShowBtn = true
				this.examineId = options.examineId
			} else {
				this.isShowBtn = false
				this.examineId = options.examineId
			}
		},

		methods: {
			agree() {
				// this.examineId = item.id
				this.$refs.agreePopup.open('center')
			},
			disagree() {
				// this.examineId = item.id
				this.$refs.isDisagree.open('center')
			},
			sureAgree(){
				this.$http.post("/crm_on_hand/crmOnHand/agreeTrial", {
					id: this.examineId
				}).then(res => {
					console.log('同意申请',res)
					if (res.data.success) {
						this.$refs.isAgree.open('center')
						this.$refs.agreePopup.close()
						let that = this
						setTimeout(()=>{
						    that.agreeCancel()
							uni.navigateTo({
								url: '/pages/toDoList/index'
							})
						},1000)
						
					}else{
						this.$tip.toast(res.data.message)
						this.$refs.agreePopup.close()
					}
				})
			},
			cancelAgree(){
				this.$refs.agreePopup.close()
			},
			agreeCancel() {
				this.$refs.isAgree.close()
			},
			rejectCancel() {
				this.$refs.isDisagree.close()
			},
			rejectSure() {
				this.$http.post("/crm_on_hand/crmOnHand/rejectTrial", {
					id: this.examineId,
					reason: this.rejectReason
				}).then(res => {
					if (res.data.success) {
						this.$refs.isDisagree.close()
						setTimeout(()=>{
							uni.navigateTo({
								url: '/pages/toDoList/index'
							})
						},1000)
					}else{
						this.$tip.toast(res.data.message)
						this.$refs.isDisagree.close()
					}
				})
			},
			getDetail() {
				this.$http.get(
						"/crm_job_transfer_application/crmJobTransferApplication/queryDetail/" + this.dataObj.id)
					.then(res => {
						console.log('调岗详情',res.data.result)
						if (res.data.success) {
							this.dataObj = res.data.result
							// this.dataObj['avatar'] = this.getFileAccessHttpUrl(this.dataObj['avatar'])
							// console.log(this.dataObj['avatar'])
							this.approvalRecords = this.dataObj.approvalRecords
							this.deviceTransferList = this.dataObj.deviceTransferList
							this.fileTransferList = this.dataObj.fileTransferList
							this.todoTransferList = this.dataObj.todoTransferList
							this.dataTransferList = this.dataObj.dataTransferList
						}
					})
			},
			searchBtn() {
				console.log(this.searchValue)
			},
			urging(id) {
				const params = {
					applicationId: id,
					approvalType: 1
				}
				this.$http.get("/crm_on_hand/crmOnHand/urge",{params:params})
					.then(res => {
						if (res.data.success) {
							this.$refs.urgingPopup.open('center')
						}
					})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.submit-icon {
		width: 118rpx;
		height: 118rpx;
		margin-top: 58rpx;
	}
	image {
		width: 100%;
		height: 100%;
	}

	.blackList {
		height: 100%;
		overflow: hidden;
	}

	.page-search {
		padding-left: 34rpx;
		margin-bottom: 12rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
	}

	.search {
		width: 680rpx;
		height: 86rpx;
		background-color: rgba(249, 249, 249, 1);
		border-radius: 60rpx;
		display: flex;
		flex-direction: row;
		align-items: center;
		padding-left: 24rpx;
		padding-right: 24rpx;

		.search-left {
			width: 28rpx;
			height: 28rpx;
			display: flex;
			justify-content: center;
			align-items: center;
		}

		.search-center {
			margin-left: 22rpx;
		}

		.search-placeholder {
			font-size: 28rpx;
			font-weight: 400;
			color: #7C7C7C;
		}


	}

	.filter-btn {
		width: 40rpx;
		height: 40rpx;
		margin-right: 42rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.page-content-main {
		height: calc(100% - 12rpx - 86rpx);
		border-top-left-radius: 64rpx;
		border-top-right-radius: 64rpx;
		padding: 26rpx 34rpx 0 34rpx
	}

	.select-box {
		display: flex;
		flex-direction: row;
		justify-content: flex-start;

	}

	.select {
		width: 160rpx;
		height: 74rpx;
		border-radius: 60rpx;
		background-color: #4591FE;
		margin-bottom: 20rpx;
		display: flex;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		margin-right: 48rpx;
		position: relative;

    .select-value {
      font-size: 28rpx;
      font-weight: 400;
      color: #FFFFFF;
      margin-right: 18rpx;
    }

    .select-icon {
      width: 22rpx;
      height: 22rpx;
      display: flex;
      justify-content: center;
      align-items: center;
      position: absolute;
      right: 20rpx;
      top:25rpx;
    }
	}

	.list {
		height: calc(100% - 74rpx - 20rpx);
	}

	.list-item {
		border-radius: 28rpx;
		background-color: #FFFFFF;
		padding: 26rpx 24rpx 28rpx 20rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		margin-bottom: 26rpx;
		position: relative;

		.list-item-leftCenter {
			display: flex;
			flex-direction: row;
		}

		.list-item-left {
			width: 86rpx;
			height: 86rpx;
			margin-right: 26rpx;
			display: flex;
			justify-content: center;
			align-items: center;
		}

		.list-item-center {
			.list-item-row {
				display: flex;
				flex-direction: row;
				margin-bottom: 20rpx;

				.list-item-name {
					color: #101317;
					font-size: 32rpx;
					margin-right: 16rpx;
				}

				.list-item-sex {
					width: 106rpx;
					height: 42rpx;
					border-top-right-radius: 40rpx;
					border-bottom-right-radius: 40rpx;
					border-bottom-left-radius: 20rpx;
					background-color: rgba(234, 171, 78, 0.35);
					line-height: 42rpx;
					text-align: center;
					color: rgba(255, 173, 4, 1);
					font-size: 24rpx;
				}

				.list-item-row-icon {
					width: 38rpx;
					height: 38rpx;
					margin-right: 10rpx;
					display: flex;
					justify-content: center;
					align-items: center;
				}

				.list-item-row-title,
				.list-item-row-value {
					font-size: 24rpx;
					font-weight: 400;
					color: #101317;
					line-height: 38rpx;
				}

			}
		}

		.list-item-btn {
			width: 36rpx;
			height: 36rpx;
			margin-top: 56rpx;
			display: flex;
			justify-content: center;
			align-items: center;
		}

		.list-item-tab {
			width: 132rpx;
			height: 56rpx;
			text-align: center;
			line-height: 56rpx;
			background-color: rgba(69, 145, 254, 0.4);
			position: absolute;
			top: 0;
			right: 0;
			border-top-right-radius: 26rpx;
			border-bottom-left-radius: 20rpx;
		}

		.list-item-tab-text {
			font-size: 26rpx;
			color: rgba(69, 145, 254, 1)
		}
	}

	.nav-right-image {
		width: 80rpx;
		height: 80rpx;
		margin-left: 15px;
	}

	.fun-wrap {
		position: absolute;
		top: 0;
		left: 0;
		width: 100%;
		height: 100%;
		background-color: rgba(3, 3, 3, 0.28);
		z-index: 10000;
	}

	.fun-box {
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		align-items: center;
		flex-wrap: wrap;
		width: 556rpx;
		height: 444rpx;
		border-top-left-radius: 42rpx;
		border-bottom-left-radius: 42rpx;
		border-bottom-right-radius: 42rpx;
		position: absolute;
		right: 74rpx;
		background-color: #FFFFFF;
		padding-top: 35rpx;
	}

	.fun-item {
		width: 185rpx;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		margin-bottom: 44rpx;
	}

	.fun-icon {
		width: 92rpx;
		height: 92rpx;
		margin-bottom: 22rpx;
	}

	.cu-form-group {
		background-color: transparent;
	}

	::v-deep {
		.cu-form-group uni-picker .picker {
			color: #FFFFFF;
		}

		.cu-form-group uni-picker::after {
			opacity: 0;
		}
	}

	.textView {
		margin-left: 25px;
		font-size: 10px;
		margin-top: 5px;
	}

	.listText {
		width: 148rpx;
		height: 24rpx;
		font-size: 20rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		color: #000000;
		line-height: 24rpx;
	}

	th {
		border: 1px solid #000000;
		border-collapse: collapse;
		text-align: center;
		max-width: 50px;
		min-width: 44px;
		overflow: auto;
		/* 隐藏超出容器的文字 */
		white-space: nowrap;
		/* 禁止换行 */
		text-overflow: ellipsis;
	}

	td {
		border: 1px solid #000000;
		border-collapse: collapse;
		padding: 1px 15px;
		text-align: center;
		max-width: 44px;
		min-width: 44px;
		overflow: hidden;
		/* 隐藏超出容器的文字 */
		white-space: nowrap;
		/* 禁止换行 */
		text-overflow: ellipsis;
		word-wrap: break-word;

	}
</style>
